<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@include file="cabecera.jsp" %>
        <link rel="stylesheet" href="./css/estilo2.css" type="text/css" /> 
        <title>Listar sucursal</title>
    </head>
    <body>
        <div class="contenedor">
            <h1>Sucursales</h1>
            <logic:notEmpty name="msg" >
                <p class='error'><bean:write name="msg"/></p>
            </logic:notEmpty>
            <logic:notEmpty name="listar" >
                <table border="1">
                    <thead>
                        <tr>
                            <th>Nombre</th>
                            <th>Direcci&oacute;n</th>
                            <th>C&oacute;digo postal</th>
                            <th>Localidad</th>
                            <th>Provincia</th>
                            <th>C&oacute;digo de sucursal</th>
                            <th>Latitud</th>
                            <th>Longitud</th>
                            <th colspan="2">Acciones</th>
                        </tr>
                    </thead>
                    <tbody>
                        <logic:iterate id="listar" name="listar" >
                            <tr>
                                <td><bean:write name="listar" property="nombre" /></td>
                                <td><bean:write name="listar" property="direccion" /></td>
                                <td><bean:write name="listar" property="cp" /></td>
                                <td><bean:write name="listar" property="localidad" /></td>
                                <td><bean:write name="listar" property="provincia" /></td>
                                <td><bean:write name="listar" property="pkSucursal" /></td>
                                <td><bean:write name="listar" property="latitud" /></td>
                                <td><bean:write name="listar" property="longitud" /></td>
                                <td>
                                    <html:form action="/EditarSucursal" >
                                        <html:hidden name="listar" property="pkSucursal"></html:hidden>
                                            <!html:submit value="Editar" />
                                        <html:image src="images/Edit.png" styleClass="button"  value="Editar"/>
                                    </html:form>
                        </td>
                        <td>
                            <html:form action="/EliminarSucursal" >
                                <html:hidden name="listar" property="pkSucursal"></html:hidden>
                                    <!html:submit value="Eliminar" />
                                <html:image src="images/Delete.png" styleClass="button"  value="Eliminar"/>
                            </html:form>
                        </td>
                        </tr>
                    </logic:iterate>
                    </tbody>
                </table>   
            </logic:notEmpty>
            <logic:empty name="listar" >
                No se ha creado ninguna sucursal.
            </logic:empty>
            <br/><br/>
            <html:link action="/GestionSucursal">Volver</html:link>
        </div>
    </body>
</html>